package com.system.web;

import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.servlet.AttributeListener;
import com.common.utils.DateUtil;
import com.system.domain.Demo_customer;
import com.system.domain.Demo_debt;
import com.system.domain.T_login_log;
import com.system.service.LogonService;
import com.system.service.LxConstans;

/**
 * 前台首页控制器
 *
 * @author davexin
 */
@Controller
public class JsonDemoController {

	private static Logger log = Logger.getLogger(JsonDemoController.class.getName());

	@RequestMapping(value = "/findCustomer")
	@ResponseBody
	public Demo_customer findCustomer(HttpServletRequest request, HttpServletResponse response){
		Demo_customer c = new Demo_customer();
		//c(1088);
		
		
		return c;
	}

	@RequestMapping(value = "/sendDebt")
	@ResponseBody
	public Demo_debt sendDebt(HttpServletRequest request, HttpServletResponse response){
		Demo_debt c = new Demo_debt();
		/*
	private Integer id;    
	private Date  djh;
	private Integer yszkje;    
	private String bz;    
	private String djrq;    
	private String customno;    
	private String company;    
	private String kz1;    
	private String kz2; 
		 */
		c.setId(1089);
		c.setDjh("shdklask198230183943213");
		c.setYszkje("370000.00");
		c.setBz("01");
		c.setDjrq("2016-08-09");
		c.setCustomno("ZHGYS001");
		c.setKz1("");
		c.setKz2("");
		c.setKz3("");
		
		return c;
	}
	
	

	/**
	 * 获取访问者ip
	 * @param request
	 * @return
	 */
	public String getIp(HttpServletRequest request) {
		String ip = request.getHeader("X-Forwarded-For");
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("Proxy-Client-IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("WL-Proxy-Client-IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("HTTP_CLIENT_IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getHeader("HTTP_X_FORWARDED_FOR");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = request.getRemoteAddr();
		}
		return ip;
	}


}
